<?php
namespace app\api\controller;

use app\common\controller\Api;
use  think\db;

/**
 * 示例接口
 */
class Money extends Api
{

    // 无需登录的接口,*表示全部
    protected $noNeedLogin = [''];
    // 无需鉴权的接口,*表示全部
    protected $noNeedRight = ['*'];


    /**
     * @return  我的余额记录
     */
    public function getallmoneylog(){

        $uid=$this->auth->id;

        $activeTab=$this->request->param('activeTab');

        $where['user_id']=['eq',$uid];


        if($activeTab=='income'){
            $where['memo']=['eq','系统充值'];
        }

        if($activeTab=='expense'){
            $where['memo']=['eq','系统扣除'];
        }


        $logs=Db::name('user_money_log')->where($where)->select();


//        echo Db::getlastSql();

        foreach ($logs as $key => $value){
            $logs[$key]['createtime']=date('Y-m-d H:i:s',$value['createtime']);
        }

        $this->success('',$logs);


    }

}